/*
 * @Author: Drswith
 * @Date: 2021-01-11 16:18:14
 * @LastEditors: Drswith
 * @LastEditTime: 2021-01-11 16:22:02
 * @FilePath: \season2\2.Hardware Software\device-2-key\device\device.ino
 */
/*    头文件      */
#include "Button2.h";

/*    引脚号宏定义      */
#define PIN_BEEP 13
#define PIN_LED  2
#define PIN_KEY_LED  14
#define PIN_KEY_BEEP  12



/*    全局变量（对象）      */
Button2 led_key = Button2(PIN_KEY_LED);
Button2 beep_key = Button2(PIN_KEY_BEEP);

/*    初始化函数      */
void setup() {
  Serial.begin(115200);
  delay(50);
  Serial.println("\n\nSave Tiro Season2 NodeMcu Arduino IDE Weapp\n\n");
  
  pinMode(PIN_LED, OUTPUT);
  pinMode(PIN_BEEP, OUTPUT);
  led_key.setTapHandler(led_tap);
  beep_key.setTapHandler(beep_tap);
}


/*    主循环函数      */
void loop() {
  digitalWrite(PIN_LED, HIGH);  
  digitalWrite(PIN_BEEP, HIGH);  
  delay(1000);                      
  digitalWrite(PIN_LED, LOW);
  digitalWrite(PIN_BEEP, LOW);     
  delay(1000); 
  led_key.loop();
  beep_key.loop();                   
}

void led_tap(Button2& btn) {
    Serial.println("led_key tap");
}
void beep_tap(Button2& btn) {
    Serial.println("beep_key tap");
}
